package com.lm.controller;
import com.lm.pojo.TeamManage;
import com.lm.service.TeamManageService;
import com.lm.service.impl.TeamManageServicempl;
import com.lm.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "团队管理")
@RestController
@CrossOrigin("*")
@RequestMapping("/teammanage")
public class TeamManageController {

    @Autowired
    private TeamManageService teamManageService;

    /**
     * 查询“我管理的团队”
     * @param doctorId 医生ID（当前登录医生，从Token中获取，此处暂用参数传递）
     */
    @ApiOperation(value = "查询我管理的团队", httpMethod = "GET", notes = "根据医生ID（团队长）查询团队列表")
    @GetMapping("/myManagedTeams")
    public ResultUtil<List<TeamManage>> findMyManagedTeams(@RequestParam("docterId") Integer doctorId) {
        try {
            List<TeamManage> teams = teamManageService.findMyTeam(doctorId);
            return new ResultUtil<>(200, "查询成功", teams);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500, "查询失败：" + e.getMessage());
        }
    }

    /**
     * 查询“我加入的团队”
     * @param doctorId 医生ID（当前登录医生）
     */
    @ApiOperation(value = "查询我加入的团队", httpMethod = "GET", notes = "根据医生ID（团队成员）查询团队列表")
    @GetMapping("/myJoinedTeams")
    public ResultUtil<List<TeamManage>> findMyJoinedTeams(@RequestParam("docterId") Integer doctorId) {
        try {
            // 调用扩展的Service方法

            return new ResultUtil<>(200, "查询成功",teamManageService.findMyJoinTeam(doctorId));
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500, "查询失败：" + e.getMessage());
        }
    }
}